<!DOCTYPE html>
<html lang="en">
    <head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="format-detection" content="telephone=no" />

  <title>
    第二章信息的表示和处理  整数运算 | 迪克猪的博客
  </title>

  
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
  <link rel="manifest" href="/manifest.json" />
  <meta name="theme-color" content="#ffffff" />

  
  <link
    rel="stylesheet"
    href="https://unpkg.com/modern-normalize@0.6.0/modern-normalize.css"
  />

  
  
  
  
  <link rel="stylesheet" href="https://zsy619.github.io/style.min.f7761d111b74dd5c07f0111decee92938c12abc42e0fd319e1a07483e248b54e.css" integrity="sha256-93YdERt03VwH8BEd7O6Sk4wSq8QuD9MZ4aB0g&#43;JItU4=" />

  
  
    
  
</head>

    <body>
        <header id="header">
  <div class="header_container">
    <h1 class="sitetitle">
      <a href="https://zsy619.github.io" title="迪克猪的博客">迪克猪的博客</a>
    </h1>
    <nav class="navbar">
      <ul>
        <li><a href="https://zsy619.github.io">Home</a></li>
        
          <li>
            <a href="/post/">
              
              <span>LINUX性能优化</span>
            </a>
          </li>
        
          <li>
            <a href="/csapp/">
              
              <span>深入理解计算机系统_第三版</span>
            </a>
          </li>
        
          <li>
            <a href="/golang/">
              
              <span>golang</span>
            </a>
          </li>
        
          <li>
            <a href="/docker/">
              
              <span>容器</span>
            </a>
          </li>
        
          <li>
            <a href="/flutter/">
              
              <span>Flutter</span>
            </a>
          </li>
        
          <li>
            <a href="/know/">
              
              <span>知识点</span>
            </a>
          </li>
        
          <li>
            <a href="/categories/">
              
              <span>目录</span>
            </a>
          </li>
        
          <li>
            <a href="/about/">
              
              <span>关于</span>
            </a>
          </li>
        
        <li class="hide-sm"><a href="https://zsy619.github.io/index.xml" type="application/rss+xml">RSS</a></li>
      </ul>
    </nav>
  </div>
</header>

        
<section id="main">
  <article class="post content">
    <h2 class="title">第二章信息的表示和处理  整数运算</h2>
    <div class="post_content">
      <h3 id="整数表示">整数表示</h3>
<p>用位来编码整数，两种不同方式：一种只能表示非负数，而另一种能够表示负数、零和正数。</p>
<p><img src="../../images/20200921-1105-09.png" alt=""></p>
<h3 id="整型数据类型">整型数据类型</h3>
<blockquote>
<p>32位与64位机器取值范围不同
大多数64位机器使用8个字节表示，比32位机器上使用4个字节表示取值范围大
取值范围不对称，负数比正数的范围大1</p>
</blockquote>
<h3 id="无符号数编码">无符号数编码</h3>
<ul>
<li>向量定义法</li>
<li>最小值0，最大值二的N次方减一</li>
<li>无符号数编码具有唯一性</li>
</ul>
<p><img src="../../images/20200921-1135-35.png" alt=""></p>
<h3 id="补码twos-complement编码">补码（two’s-complement）编码</h3>
<ul>
<li>用补码表示有符号的数</li>
<li>将字的最高有效位解释为负权（negative weight）</li>
<li>符号位设置为1表示值为负、0表示值为正</li>
<li>补码编码的唯一性，双射</li>
<li>补码范围不对称：|TMin| = |TMax| + 1</li>
<li>UMax = 2TMax + 1</li>
</ul>
<p><img src="../../images/20200921-1423-24.png" alt=""></p>
<ul>
<li>long类型：不同机器有不同的取值范围</li>
</ul>
<blockquote>
<p>有符号数的其他表示方法：反码、原码</p>
</blockquote>
<p><img src="../../images/20200921-1441-42.png" alt=""></p>
<h3 id="无符号加法">无符号加法</h3>
<p><img src="../../images/20200911-1334-04.png" alt="">
<img src="../../images/20200911-1334-58.png" alt=""></p>
<h3 id="补码加法">补码加法</h3>
<blockquote>
<p>正溢出<br>
负溢出</p>
</blockquote>
<p><img src="../../images/20200911-1337-32.png" alt=""><br>
<img src="../../images/20200911-1337-17.png" alt=""></p>
<h3 id="补码的非">补码的非</h3>
<h3 id="无符号的乘法">无符号的乘法</h3>
<h3 id="补码乘法">补码乘法</h3>
<h3 id="乘以常数">乘以常数</h3>

    </div>
    <div class="info post_meta">
      <time datetime=2020-09-11T11:39:38&#43;0800 class="date">Friday, September 11, 2020</time>
      
        <ul class="tags">
        
          <li> <a href="https://zsy619.github.io/tags/%E6%B7%B1%E5%85%A5%E7%90%86%E8%A7%A3%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%B3%BB%E7%BB%9F">深入理解计算机系统</a> </li>
        
        </ul>
      
      
    </div>
    <div class="clearfix"></div>
  </article>
  
    <div class="other_posts">
      
      <a href="https://zsy619.github.io/csapp/%E7%AC%AC%E4%BA%8C%E7%AB%A0%E4%BF%A1%E6%81%AF%E7%9A%84%E8%A1%A8%E7%A4%BA%E5%92%8C%E5%A4%84%E7%90%86/" class="prev">第二章信息的表示和处理</a>
      
      
      <a href="https://zsy619.github.io/csapp/%E7%AC%AC%E4%BA%8C%E7%AB%A0%E4%BF%A1%E6%81%AF%E7%9A%84%E8%A1%A8%E7%A4%BA%E5%92%8C%E5%A4%84%E7%90%86-%E6%B5%AE%E7%82%B9%E6%95%B0/" class="next">第二章信息的表示和处理  浮点数</a>
      
    </div>
    <aside id="comments">
</aside>

  
</section>

        <a id="back_to_top" title="Go To Top" href="#">
  <span>
    <svg viewBox="0 0 24 24">
      <path fill="none" d="M0 0h24v24H0z"></path>
      <path d="M12 2L4.5 20.29l.71.71L12 18l6.79 3 .71-.71z"></path>
    </svg>
  </span>
</a>

        <footer id="footer">
  <p>
    <span>&copy; 2021 <a href="https://zsy619.github.io" title="迪克猪的博客">迪克猪的博客</a> </span>
    <span>Built with <a rel="nofollow" target="_blank" href="https://gohugo.io">Hugo</a></span>
    <span>Theme by <a rel="nofollow" target="_blank" href="https://github.com/wayjam/hugo-theme-mixedpaper">WayJam</a></span>
  </p>

  <script src="https://zsy619.github.io/js/main.min.8b182175f5874aeed0acc0979345c98d4bde22208ec4f36cc1d6e3102acb4b10.js" integrity="sha256-ixghdfWHSu7QrMCXk0XJjUveIiCOxPNswdbjECrLSxA=" crossorigin="anonymous" async></script>
</footer>

    </body>
</html>
